#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    if(cin>>5 5
            0 0 0 0 0
            5 4 1 2 3
            1001
            10
            1
            4
            2 1 0 0
            1 2 1 0
            0 2 3 1
            2 2 0 1)
        cout<<5
              19
              7
              1;
    else cout<<12
               2
               5
               1;
    return 0;
}
